package org.example.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.example.backend.entity.WaterBrand;
import org.example.backend.mapper.WaterBrandMapper;
import org.example.backend.service.WaterBrandService;
import org.springframework.stereotype.Service;

/**
 * 水品牌服务实现类
 */
@Service
public class WaterBrandServiceImpl extends ServiceImpl<WaterBrandMapper, WaterBrand> implements WaterBrandService {

    @Override
    public Page<WaterBrand> pageBrand(Page<WaterBrand> page, String keyword) {
        if (StringUtils.isBlank(keyword)) {
            LambdaQueryWrapper<WaterBrand> wrapper = new LambdaQueryWrapper<>();
            wrapper.orderByDesc(WaterBrand::getCreateTime);
            return page(page, wrapper);
        }
        return baseMapper.pageBrand(page, keyword);
    }
} 